/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "productos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Productos.findAll", query = "SELECT p FROM Productos p"),
    @NamedQuery(name = "Productos.findByIdProd", query = "SELECT p FROM Productos p WHERE p.idProd = :idProd"),
    @NamedQuery(name = "Productos.findByCodProd", query = "SELECT p FROM Productos p WHERE p.codProd = :codProd"),
    @NamedQuery(name = "Productos.findByDescripcion", query = "SELECT p FROM Productos p WHERE p.descripcion = :descripcion"),
    @NamedQuery(name = "Productos.findByStock", query = "SELECT p FROM Productos p WHERE p.stock = :stock"),
    @NamedQuery(name = "Productos.findByPrecioTaller", query = "SELECT p FROM Productos p WHERE p.precioTaller = :precioTaller")})
public class Productos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "id_Prod")
    private int idProd;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Cod_Prod")
    private String codProd;
    @Size(max = 60)
    @Column(name = "Descripcion")
    private String descripcion;
    @Column(name = "Stock")
    private Integer stock;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 11)
    @Column(name = "Precio_Taller")
    private String precioTaller;
    @Lob
    @Size(max = 65535)
    @Column(name = "Informacion")
    private String informacion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProd")
    private Collection<MotoProd> motoProdCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProd")
    private Collection<SucuProd> sucuProdCollection;
    @JoinColumn(name = "id_Subcategoria", referencedColumnName = "id_Subcategoria")
    @ManyToOne
    private Subcategorias idSubcategoria;
    @JoinColumn(name = "id_Subrama", referencedColumnName = "id_Subrama")
    @ManyToOne
    private Subramas idSubrama;
    @JoinColumn(name = "id_Rama", referencedColumnName = "id_Rama")
    @ManyToOne(optional = false)
    private Ramas idRama;
    @JoinColumn(name = "id_Marca", referencedColumnName = "id_Marca")
    @ManyToOne
    private Marcas idMarca;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProd")
    private Collection<ProdPorDetalleOrdenTrabajo> prodPorDetalleOrdenTrabajoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProd")
    private Collection<Insumos> insumosCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProd")
    private Collection<TallerProvProd> tallerProvProdCollection;

    public Productos() {
    }

    public Productos(String codProd) {
        this.codProd = codProd;
    }

    public Productos(String codProd, int idProd, String precioTaller) {
        this.codProd = codProd;
        this.idProd = idProd;
        this.precioTaller = precioTaller;
    }

    public int getIdProd() {
        return idProd;
    }

    public void setIdProd(int idProd) {
        this.idProd = idProd;
    }

    public String getCodProd() {
        return codProd;
    }

    public void setCodProd(String codProd) {
        this.codProd = codProd;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public String getPrecioTaller() {
        return precioTaller;
    }

    public void setPrecioTaller(String precioTaller) {
        this.precioTaller = precioTaller;
    }

    public String getInformacion() {
        return informacion;
    }

    public void setInformacion(String informacion) {
        this.informacion = informacion;
    }

    @XmlTransient
    public Collection<MotoProd> getMotoProdCollection() {
        return motoProdCollection;
    }

    public void setMotoProdCollection(Collection<MotoProd> motoProdCollection) {
        this.motoProdCollection = motoProdCollection;
    }

    @XmlTransient
    public Collection<SucuProd> getSucuProdCollection() {
        return sucuProdCollection;
    }

    public void setSucuProdCollection(Collection<SucuProd> sucuProdCollection) {
        this.sucuProdCollection = sucuProdCollection;
    }

    public Subcategorias getIdSubcategoria() {
        return idSubcategoria;
    }

    public void setIdSubcategoria(Subcategorias idSubcategoria) {
        this.idSubcategoria = idSubcategoria;
    }

    public Subramas getIdSubrama() {
        return idSubrama;
    }

    public void setIdSubrama(Subramas idSubrama) {
        this.idSubrama = idSubrama;
    }

    public Ramas getIdRama() {
        return idRama;
    }

    public void setIdRama(Ramas idRama) {
        this.idRama = idRama;
    }

    public Marcas getIdMarca() {
        return idMarca;
    }

    public void setIdMarca(Marcas idMarca) {
        this.idMarca = idMarca;
    }

    @XmlTransient
    public Collection<ProdPorDetalleOrdenTrabajo> getProdPorDetalleOrdenTrabajoCollection() {
        return prodPorDetalleOrdenTrabajoCollection;
    }

    public void setProdPorDetalleOrdenTrabajoCollection(Collection<ProdPorDetalleOrdenTrabajo> prodPorDetalleOrdenTrabajoCollection) {
        this.prodPorDetalleOrdenTrabajoCollection = prodPorDetalleOrdenTrabajoCollection;
    }

    @XmlTransient
    public Collection<Insumos> getInsumosCollection() {
        return insumosCollection;
    }

    public void setInsumosCollection(Collection<Insumos> insumosCollection) {
        this.insumosCollection = insumosCollection;
    }

    @XmlTransient
    public Collection<TallerProvProd> getTallerProvProdCollection() {
        return tallerProvProdCollection;
    }

    public void setTallerProvProdCollection(Collection<TallerProvProd> tallerProvProdCollection) {
        this.tallerProvProdCollection = tallerProvProdCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codProd != null ? codProd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Productos)) {
            return false;
        }
        Productos other = (Productos) object;
        if ((this.codProd == null && other.codProd != null) || (this.codProd != null && !this.codProd.equals(other.codProd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Productos[ codProd=" + codProd + " ]";
    }
    
}
